﻿#pragma once
/*
#include <math.h>  
#include<iostream>    
#include <opencv2/core/core.hpp>      
#include <opencv2/highgui/highgui.hpp>   
#include<imgproc/imgproc.hpp> 
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include "afxwin.h"*/

using namespace std;
using namespace cv;
// Copencv 对话框

class Copencv : public CDialogEx
{
	DECLARE_DYNAMIC(Copencv)

public:
	Copencv(CWnd* pParent = nullptr);   // 标准构造函数
	virtual ~Copencv();
	void* m_mdlg;
	void SetMainDlgPtr(void* pdlg) { m_mdlg = pdlg; }
// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_DIG_cv };
#endif

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnBnClickedCancel();
	//afx_msg void OnBnClickedButtonauotprg();
	afx_msg void OnBnClicked1000();
	//afx_msg void OnBnClickedOk();
	//afx_msg void OnBnClicked1001();
	afx_msg void OnBnClickedButton1openca();
	virtual BOOL OnInitDialog();
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	
	virtual BOOL PreTranslateMessage(MSG* pMsg);

	void  DrawPicToHDC(IplImage *img, UINT ID);
	void Contorscir(vector<Point2f>&centery, vector<float>&radiusy);
	void houcir(vector<Point2f>&centery, vector<float>&radiusy);

	void outcir(Mat &im, vector<Point2f>&centery, vector<float>&radiusy);
	void savecfgcv();
	void loadcfgcv();
	int hbtxy(vector<Point2f>&cen, vector<float>&ra);
	double m_bs;//放大倍数
	int m_qd1; //识别区域原点
	int m_qd2;//识别区域原点
	int m_qyx, m_qyy;//识别区域范围
	double m_lenline;//最短直线长度
	double m_mincir;//最小圆直径
	double m_maxcir;//最大圆直径
	int m_countline;//识别的直线数量
	int m_countcir = 0;//识别的圆的数量
	double m_yd;//圆度
	int m_fblx;//分辨率
	int m_fbly;//分辨率
	int m_element;//元素类型
	double m_fz1, m_fz2;//阈值
	// 圆识别累加图像分辨率	// 圆识别累加图像分辨率	// 圆识别累加图像分辨率	// 圆识别累加图像分辨率
	double m_cirdp;
	// 圆识别最小圆心距
	double m_cirmd;
	double m_img1x, m_img1y, m_img2x, m_img2y;
	struct pstr
	{
		double a, b;
		double r;
	};

	static bool sortFun1(const pstr &ps1, const pstr& ps2);
	static bool sortFun2(const pstr &ps1, const pstr& ps2);
	static bool sortFun3(const pstr &ps1, const pstr& ps2);
	static bool sortFun4(const pstr &ps1, const pstr& ps2);

	afx_msg void OnBnClickedButtonsavecfg();
	float m1x,m1y,m2x,m2y,im1x,im1y,im2x,im2y;
	
	float m_blxs;
	CComboBox m_gjlx;

	DOUBLE m_aqjl;
	DOUBLE m_gzm;
	double  GetEditFloat(UINT id);
	afx_msg void OnBnClickedButtonsetbd1();
	afx_msg void OnBnClickedButton1Mabd();
	afx_msg void OnBnClickedButtonsetbd2();
	afx_msg void OnBnClickedButtoncat();
	afx_msg void OnBnClickedButton1();
};
